﻿namespace LinesOfAction.Controls
{
    using System.ComponentModel;
    using System.Runtime.CompilerServices;
    using System.Windows;
    using System.Windows.Input;
    using Enumerations;

    /// <summary>
    ///   Interaction logic for Piece.xaml
    /// </summary>
    public sealed partial class Piece : INotifyPropertyChanged
    {
        public Players Player
        {
            get { return (Players)GetValue(PlayerProperty); }
            set { SetValue(PlayerProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Player.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty PlayerProperty =
            DependencyProperty.Register("Player", typeof(Players), typeof(Piece), new PropertyMetadata(Players.Player1));

        private int row;

        public int Row
        {
            get { return row; }
            set 
            { 
                row = value; 
                OnPropertyChanged();    
            }
        }

        private int column;

        public int Column
        {
            get { return column; }
            set
            {
                column = value;
                OnPropertyChanged();
            }
        }

        public Piece()
        {
            InitializeComponent();
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        private void OnPropertyChanged([CallerMemberName] string propertyName = "")
        {
            var handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }

        private void Piece_OnLoaded(object _sender, RoutedEventArgs _e)
        {
            DataContext = this;
        }

        private void Piece_OnMouseUp(object _sender, MouseButtonEventArgs _e)
        {
            
        }
    }
}